<!DOCTYPE html>
<html>

  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<meta http-equiv="Cache-Control" content="no-siteapp" />

    <title>xmake v2.2.1 released, Support Qt, WDK and Cuda Compilation Environments</title>
    <meta name="description" content="To make xmake more convenient and flexible to support other compilation environments, I spent four months to upgrade custom rule rules.Users can now implemen...">

    
    <meta name="keywords" content="xmake,lua,update,Qt,WDK,Cuda,tboox" /> 

    <!-- qq oauth -->
    <meta property="qc:admins" content="5211601217706727767255" />

    <!--icon -->
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
    <link rel="icon" sizes="192x192" href="/static/img/nice-highres.png" />
	<link rel="apple-touch-icon-precomposed" href="/static/img/apple-touch-icon-57x57-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="72x72" href="/static/img/apple-touch-icon-72x72-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="114x114" href="/static/img/apple-touch-icon-114x114-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="144x144" href="/static/img/apple-touch-icon-144x144-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="180x180" href="/static/img/retinahd_icon.png" />
	<meta name="msapplication-TileImage" content="/static/img/retinahd_icon.png" />
	
    <link rel="stylesheet" href=" /css/fontawesome/css/font-awesome.min.css ">
    <link rel="stylesheet" href=" /css/main.css ">
    <link rel="canonical" href="https://tboox.org/2018/06/17/update-v2.2.1/">
    <link rel="alternate" type="application/rss+xml" title="TBOOX Open Source Project" href="https://tboox.org/feed.xml ">
    <link rel="alternate" hreflang="en" href="https://tboox.org/" />
    <link rel="alternate" hreflang="zh-Hans" href="https://tboox.org/cn/" />




    <script type="text/javascript">
    function isPC(){    
        var userAgentInfo = navigator.userAgent;  
        var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod");    
        var flag = true;    
        for (var v = 0; v < Agents.length; v++) {    
            if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; }    
        }    
        return flag;    
    }
    </script>

<!-- baidu ads -->



    <!-- baidu ads -->

</head>


  <body>

    <header id="top">
    <div class="wrapper">
        <a href="/" class="brand">TBOOX</a>
        <button id="headerMenu" class="menu"><i class="fa fa-bars"></i></button>
        <nav id="headerNav">
            <ul>
                <li>
                    
                    <a href="/cn?lang=0">
                    
                        <i class="fa fa-home"></i>中文
                    </a>
                </li>

                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="/project/">
                            
                        
                            <i class="fa fa-bookmark"></i>Projects
                        </a>
                    </li>
                    
                    
                    
                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="/archive/">
                            
                        
                            <i class="fa fa-archive"></i>Archives
                        </a>
                    </li>
                    
                    
                    
                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="/category/">
                            
                        
                            <i class="fa fa-th-list"></i>Categories
                        </a>
                    </li>
                    
                    
                    
                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="/tag/">
                            
                        
                            <i class="fa fa-tags"></i>Tags
                        </a>
                    </li>
                    
                    
                    
                
                    
                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="/docs/">
                            
                        
                            <i class="fa fa-book"></i>Documents
                        </a>
                    </li>
                    
                    
                    
                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="https://xmake.io/#/about/contact" target="_blank" >
                            
                        
                            <i class="fa fa-forumbee"></i>Community
                        </a>
                    </li>
                    
                    
                    
                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="/donation/">
                            
                        
                            <i class="fa fa-heart"></i>Donate
                        </a>
                    </li>
                    
                    
                    
                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="/about/">
                            
                        
                            <i class="fa fa-user"></i>About
                        </a>
                    </li>
                    
                    
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                     
                     
                    
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            </ul>
        </nav>
    </div>
</header>



        <div class="page clearfix" post>
    <div class="left">
        <h1>xmake v2.2.1 released, Support Qt, WDK and Cuda Compilation Environments</h1>
        <div class="label">

            <div class="label-card">
                <i class="fa fa-calendar"></i>2018-06-17
            </div>

            <div class="label-card">
                
            </div>

            <div class="label-card">
                
            </div>

            <div class="label-card">
            


<!-- <span class="point">•</span> -->
<span class="categories">
  <i class="fa fa-th-list"></i>
  
    
        <a href="/category/#xmake" title="Category: xmake" rel="category">xmake</a>
    
  

  <!-- <span class="point">•</span> -->
</span>


            </div>

            <div class="label-card">
            
<!-- <span class="point">•</span> -->
<span class="pageTag">
  <i class="fa fa-tags"></i>
  
    
        <!--a href="/tag/#xmake" title="Tag: xmake" rel="tag">xmake</a-->
        <a href="/tag/#xmake" title="Tag: xmake" rel="tag">xmake</a>&nbsp;
    
        <!--a href="/tag/#lua" title="Tag: lua" rel="tag">lua</a-->
        <a href="/tag/#lua" title="Tag: lua" rel="tag">lua</a>&nbsp;
    
        <!--a href="/tag/#update" title="Tag: update" rel="tag">update</a-->
        <a href="/tag/#update" title="Tag: update" rel="tag">update</a>&nbsp;
    
        <!--a href="/tag/#Qt" title="Tag: Qt" rel="tag">Qt</a-->
        <a href="/tag/#Qt" title="Tag: Qt" rel="tag">Qt</a>&nbsp;
    
        <!--a href="/tag/#WDK" title="Tag: WDK" rel="tag">WDK</a-->
        <a href="/tag/#WDK" title="Tag: WDK" rel="tag">WDK</a>&nbsp;
    
        <!--a href="/tag/#Cuda" title="Tag: Cuda" rel="tag">Cuda</a-->
        <a href="/tag/#Cuda" title="Tag: Cuda" rel="tag">Cuda</a>
    
  

</span>

            </div>

        </div>
        <hr>
        <article itemscope itemtype="http://schema.org/BlogPosting">
        <p>To make <a href="https://github.com/xmake-io/xmake">xmake</a> more convenient and flexible to support other compilation environments, I spent four months to upgrade <a href="https://xmake.io/#/manual?id=custom-rule">custom rule rules</a>.</p>

<p>Users can now implement various compilation rules by customizing the rules, and xmake also has built-in common compilation rules that can be applied directly to the current project to support QT, WDK driver and Cuda compilation environments.</p>

<ul>
  <li><a href="https://github.com/xmake-io/xmake">Github Repo</a></li>
  <li><a href="https://xmake.io/#/home">Online documents</a></li>
</ul>

<p>Relative articles：</p>

<ul>
  <li><a href="http://tboox.org/2018/05/30/support-qt/">XMake: Support for the Qt SDK environment</a></li>
</ul>

<h3 id="new-features">New features</h3>

<ul>
  <li><a href="https://github.com/xmake-io/xmake/issues/158">#158</a>: Support CUDA Toolkit and Compiler</li>
  <li>Add <code class="highlighter-rouge">set_tools</code> and <code class="highlighter-rouge">add_tools</code> apis to change the toolchains for special target</li>
  <li>Add builtin rules: <code class="highlighter-rouge">mode.debug</code>, <code class="highlighter-rouge">mode.release</code>, <code class="highlighter-rouge">mode.profile</code> and <code class="highlighter-rouge">mode.check</code></li>
  <li>Add <code class="highlighter-rouge">is_mode</code>, <code class="highlighter-rouge">is_arch</code> and <code class="highlighter-rouge">is_plat</code> builtin apis in the custom scripts</li>
  <li>Add color256 codes</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/160">#160</a>: Support Qt compilation environment and add <code class="highlighter-rouge">qt.console</code>, <code class="highlighter-rouge">qt.application</code> rules</li>
  <li>Add some Qt project templates</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/169">#169</a>: Support yasm for linux, macosx and windows</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/159">#159</a>: Support WDK driver compilation environment</li>
</ul>

<h3 id="changes">Changes</h3>

<ul>
  <li>Add FAQ to the auto-generated xmake.lua</li>
  <li>Support android NDK &gt;= r14</li>
  <li>Improve warning flags for swiftc</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/167">#167</a>: Improve custom rules</li>
  <li>Improve <code class="highlighter-rouge">os.files</code> and <code class="highlighter-rouge">os.dirs</code> api</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/171">#171</a>: Improve build dependence for qt rule</li>
  <li>Implement <code class="highlighter-rouge">make clean</code> for generating makefile plugin</li>
</ul>

<h3 id="bugs-fixed">Bugs fixed</h3>

<ul>
  <li>Fix force to add flags bug</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/157">#157</a>: Fix generate pdb file error if it’s output directory does not exists</li>
  <li>Fix strip all symbols bug for macho target file</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/168">#168</a>: Fix generate vs201x project bug with x86/x64 architectures</li>
</ul>

<h3 id="introduction-to-new-features">Introduction to New features</h3>

<h4 id="qt-program">Qt Program</h4>

<p>Create an empty project:</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> create -l c++ -t console_qt test
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> create -l c++ -t static_qt test
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> create -l c++ -t shared_qt test
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> create -l c++ -t quickapp_qt test
</span></code></pre>
</div>

<p>xmake will detect Qt SDK automatically and we can also set the SDK directory manually.</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> f --qt=~/Qt/Qt5.9.1
</span></code></pre>
</div>

<p>If you want to known more information, you can see <a href="https://github.com/xmake-io/xmake/issues/160">#160</a>.</p>

<h5 id="static-library">Static Library</h5>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">target</span><span class="p">(</span><span class="s2">"qt_static_library"</span><span class="p">)</span>
    <span class="n">add_rules</span><span class="p">(</span><span class="s2">"qt.static"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.cpp"</span><span class="p">)</span>
    <span class="n">add_frameworks</span><span class="p">(</span><span class="s2">"QtNetwork"</span><span class="p">,</span> <span class="s2">"QtGui"</span><span class="p">)</span>
</code></pre>
</div>

<h5 id="shared-library">Shared Library</h5>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">target</span><span class="p">(</span><span class="s2">"qt_shared_library"</span><span class="p">)</span>
    <span class="n">add_rules</span><span class="p">(</span><span class="s2">"qt.shared"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.cpp"</span><span class="p">)</span>
    <span class="n">add_frameworks</span><span class="p">(</span><span class="s2">"QtNetwork"</span><span class="p">,</span> <span class="s2">"QtGui"</span><span class="p">)</span>
</code></pre>
</div>

<h5 id="console-program">Console Program</h5>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">target</span><span class="p">(</span><span class="s2">"qt_console"</span><span class="p">)</span>
    <span class="n">add_rules</span><span class="p">(</span><span class="s2">"qt.console"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.cpp"</span><span class="p">)</span>
</code></pre>
</div>

<h5 id="quick-application">Quick Application</h5>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">target</span><span class="p">(</span><span class="s2">"qt_quickapp"</span><span class="p">)</span>
    <span class="n">add_rules</span><span class="p">(</span><span class="s2">"qt.application"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.cpp"</span><span class="p">)</span> 
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/qml.qrc"</span><span class="p">)</span>
    <span class="n">add_frameworks</span><span class="p">(</span><span class="s2">"QtQuick"</span><span class="p">)</span>
</code></pre>
</div>

<h5 id="widgets-application">Widgets Application</h5>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">target</span><span class="p">(</span><span class="s2">"qt_widgetapp"</span><span class="p">)</span>
    <span class="n">add_rules</span><span class="p">(</span><span class="s2">"qt.application"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.cpp"</span><span class="p">)</span> 
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/mainwindow.ui"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/mainwindow.h"</span><span class="p">)</span>  <span class="c1">-- add files with Q_OBJECT meta (only for qt.moc)</span>
    <span class="n">add_frameworks</span><span class="p">(</span><span class="s2">"QtWidgets"</span><span class="p">)</span>
</code></pre>
</div>

<h4 id="cuda-program">Cuda Program</h4>

<p>Create an empty project:</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> create -P test -l cuda
</span><span class="w">$ </span><span class="nc">cd</span><span class="kv"> test
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv">
</span></code></pre>
</div>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">target</span><span class="p">(</span><span class="s2">"cuda_console"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.cu"</span><span class="p">)</span>

    <span class="c1">-- generate SASS code for each SM architecture</span>
    <span class="k">for</span> <span class="n">_</span><span class="p">,</span> <span class="n">sm</span> <span class="k">in</span> <span class="nb">ipairs</span><span class="p">({</span><span class="s2">"30"</span><span class="p">,</span> <span class="s2">"35"</span><span class="p">,</span> <span class="s2">"37"</span><span class="p">,</span> <span class="s2">"50"</span><span class="p">,</span> <span class="s2">"52"</span><span class="p">,</span> <span class="s2">"60"</span><span class="p">,</span> <span class="s2">"61"</span><span class="p">,</span> <span class="s2">"70"</span><span class="p">})</span> <span class="k">do</span>
        <span class="n">add_cuflags</span><span class="p">(</span><span class="s2">"-gencode arch=compute_"</span> <span class="o">..</span> <span class="n">sm</span> <span class="o">..</span> <span class="s2">",code=sm_"</span> <span class="o">..</span> <span class="n">sm</span><span class="p">)</span>
        <span class="n">add_ldflags</span><span class="p">(</span><span class="s2">"-gencode arch=compute_"</span> <span class="o">..</span> <span class="n">sm</span> <span class="o">..</span> <span class="s2">",code=sm_"</span> <span class="o">..</span> <span class="n">sm</span><span class="p">)</span>
    <span class="k">end</span>

    <span class="c1">-- generate PTX code from the highest SM architecture to guarantee forward-compatibility</span>
    <span class="n">sm</span> <span class="o">=</span> <span class="s2">"70"</span>
    <span class="n">add_cuflags</span><span class="p">(</span><span class="s2">"-gencode arch=compute_"</span> <span class="o">..</span> <span class="n">sm</span> <span class="o">..</span> <span class="s2">",code=compute_"</span> <span class="o">..</span> <span class="n">sm</span><span class="p">)</span>
    <span class="n">add_ldflags</span><span class="p">(</span><span class="s2">"-gencode arch=compute_"</span> <span class="o">..</span> <span class="n">sm</span> <span class="o">..</span> <span class="s2">",code=compute_"</span> <span class="o">..</span> <span class="n">sm</span><span class="p">)</span>
</code></pre>
</div>

<p>xmake will detect Cuda SDK automatically and we can also set the SDK directory manually.</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> f --cuda=/usr/local/cuda-9.1/ 
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv">
</span></code></pre>
</div>

<p>If you want to known more information, you can see <a href="https://github.com/xmake-io/xmake/issues/158">#158</a>.</p>

<h4 id="wdk-driver-program">WDK Driver Program</h4>

<p>xmake will detect WDK automatically and we can also set the WDK directory manually.</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> f --wdk="G:\Program Files\Windows Kits\10" -c
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv">
</span></code></pre>
</div>

<p>If you want to known more information, you can see <a href="https://github.com/xmake-io/xmake/issues/159">#159</a>.</p>

<h5 id="umdf-driver-program">UMDF Driver Program</h5>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">target</span><span class="p">(</span><span class="s2">"echo"</span><span class="p">)</span>
    <span class="n">add_rules</span><span class="p">(</span><span class="s2">"wdk.driver"</span><span class="p">,</span> <span class="s2">"wdk.env.umdf"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"driver/*.c"</span><span class="p">)</span> 
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"driver/*.inx"</span><span class="p">)</span>
    <span class="n">add_includedirs</span><span class="p">(</span><span class="s2">"exe"</span><span class="p">)</span>

<span class="n">target</span><span class="p">(</span><span class="s2">"app"</span><span class="p">)</span>
    <span class="n">add_rules</span><span class="p">(</span><span class="s2">"wdk.binary"</span><span class="p">,</span> <span class="s2">"wdk.env.umdf"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"exe/*.cpp"</span><span class="p">)</span> 
</code></pre>
</div>

<h5 id="kmdf-driver-program">KMDF Driver Program</h5>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">target</span><span class="p">(</span><span class="s2">"nonpnp"</span><span class="p">)</span>
    <span class="n">add_rules</span><span class="p">(</span><span class="s2">"wdk.driver"</span><span class="p">,</span> <span class="s2">"wdk.env.kmdf"</span><span class="p">)</span>
    <span class="n">add_values</span><span class="p">(</span><span class="s2">"wdk.tracewpp.flags"</span><span class="p">,</span> <span class="s2">"-func:TraceEvents(LEVEL,FLAGS,MSG,...)"</span><span class="p">,</span> <span class="s2">"-func:Hexdump((LEVEL,FLAGS,MSG,...))"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"driver/*.c"</span><span class="p">,</span> <span class="p">{</span><span class="n">rule</span> <span class="o">=</span> <span class="s2">"wdk.tracewpp"</span><span class="p">})</span> 
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"driver/*.rc"</span><span class="p">)</span>

<span class="n">target</span><span class="p">(</span><span class="s2">"app"</span><span class="p">)</span>
    <span class="n">add_rules</span><span class="p">(</span><span class="s2">"wdk.binary"</span><span class="p">,</span> <span class="s2">"wdk.env.kmdf"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"exe/*.c"</span><span class="p">)</span> 
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"exe/*.inf"</span><span class="p">)</span>
</code></pre>
</div>

<h5 id="wdm-driver-program">WDM Driver Program</h5>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">target</span><span class="p">(</span><span class="s2">"kcs"</span><span class="p">)</span>
    <span class="n">add_rules</span><span class="p">(</span><span class="s2">"wdk.driver"</span><span class="p">,</span> <span class="s2">"wdk.env.wdm"</span><span class="p">)</span>
    <span class="n">add_values</span><span class="p">(</span><span class="s2">"wdk.man.flags"</span><span class="p">,</span> <span class="s2">"-prefix Kcs"</span><span class="p">)</span>
    <span class="n">add_values</span><span class="p">(</span><span class="s2">"wdk.man.resource"</span><span class="p">,</span> <span class="s2">"kcsCounters.rc"</span><span class="p">)</span>
    <span class="n">add_values</span><span class="p">(</span><span class="s2">"wdk.man.header"</span><span class="p">,</span> <span class="s2">"kcsCounters.h"</span><span class="p">)</span>
    <span class="n">add_values</span><span class="p">(</span><span class="s2">"wdk.man.counter_header"</span><span class="p">,</span> <span class="s2">"kcsCounters_counters.h"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"*.c"</span><span class="p">,</span> <span class="s2">"*.rc"</span><span class="p">,</span> <span class="s2">"*.man"</span><span class="p">)</span> 
</code></pre>
</div>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">target</span><span class="p">(</span><span class="s2">"msdsm"</span><span class="p">)</span>
    <span class="n">add_rules</span><span class="p">(</span><span class="s2">"wdk.driver"</span><span class="p">,</span> <span class="s2">"wdk.env.wdm"</span><span class="p">)</span>
    <span class="n">add_values</span><span class="p">(</span><span class="s2">"wdk.tracewpp.flags"</span><span class="p">,</span> <span class="s2">"-func:TracePrint((LEVEL,FLAGS,MSG,...))"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"*.c"</span><span class="p">,</span> <span class="p">{</span><span class="n">rule</span> <span class="o">=</span> <span class="s2">"wdk.tracewpp"</span><span class="p">})</span> 
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"*.rc"</span><span class="p">,</span> <span class="s2">"*.inf"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"*.mof|msdsm.mof"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"msdsm.mof"</span><span class="p">,</span> <span class="p">{</span><span class="n">values</span> <span class="o">=</span> <span class="p">{</span><span class="n">wdk_mof_header</span> <span class="o">=</span> <span class="s2">"msdsmwmi.h"</span><span class="p">}})</span> 
</code></pre>
</div>

<h5 id="package-driver">Package Driver</h5>

<p>We can run the following command to generate a .cab driver package.</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> [p|package]
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> [p|package] -o outputdir
</span></code></pre>
</div>

<p>The output files like:</p>

<div class="highlighter-rouge"><pre class="highlight"><code>  - drivers
    - sampledsm
       - debug/x86/sampledsm.cab
       - release/x64/sampledsm.cab
       - debug/x86/sampledsm.cab
       - release/x64/sampledsm.cab
</code></pre>
</div>

<h5 id="driver-signing">Driver Signing</h5>

<p>The driver signing is disabled when we compile driver in default case, 
but we can add <code class="highlighter-rouge">set_values("wdk.sign.mode")</code> to enable test/release sign.</p>

<h6 id="testsign">TestSign</h6>

<p>We can use test certificate of xmake to do testsign, but please run <code class="highlighter-rouge">$xmake l utils.wdk.testcert</code> install as admin to install a test certificate first (only once)!</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">target</span><span class="p">(</span><span class="s2">"msdsm"</span><span class="p">)</span>
    <span class="n">add_rules</span><span class="p">(</span><span class="s2">"wdk.driver"</span><span class="p">,</span> <span class="s2">"wdk.env.wdm"</span><span class="p">)</span>
    <span class="n">set_values</span><span class="p">(</span><span class="s2">"wdk.sign.mode"</span><span class="p">,</span> <span class="s2">"test"</span><span class="p">)</span>
</code></pre>
</div>

<p>Or we set a valid certificate thumbprint to do it in local machine.</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">target</span><span class="p">(</span><span class="s2">"msdsm"</span><span class="p">)</span>
    <span class="n">add_rules</span><span class="p">(</span><span class="s2">"wdk.driver"</span><span class="p">,</span> <span class="s2">"wdk.env.wdm"</span><span class="p">)</span>
    <span class="n">set_values</span><span class="p">(</span><span class="s2">"wdk.sign.mode"</span><span class="p">,</span> <span class="s2">"test"</span><span class="p">)</span>
    <span class="n">set_values</span><span class="p">(</span><span class="s2">"wdk.sign.thumbprint"</span><span class="p">,</span> <span class="s2">"032122545DCAA6167B1ADBE5F7FDF07AE2234AAA"</span><span class="p">)</span>
</code></pre>
</div>

<p>We can also do testsign via setting store/company info.</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">target</span><span class="p">(</span><span class="s2">"msdsm"</span><span class="p">)</span>
    <span class="n">add_rules</span><span class="p">(</span><span class="s2">"wdk.driver"</span><span class="p">,</span> <span class="s2">"wdk.env.wdm"</span><span class="p">)</span>
    <span class="n">set_values</span><span class="p">(</span><span class="s2">"wdk.sign.mode"</span><span class="p">,</span> <span class="s2">"test"</span><span class="p">)</span>
    <span class="n">set_values</span><span class="p">(</span><span class="s2">"wdk.sign.store"</span><span class="p">,</span> <span class="s2">"PrivateCertStore"</span><span class="p">)</span>
    <span class="n">set_values</span><span class="p">(</span><span class="s2">"wdk.sign.company"</span><span class="p">,</span> <span class="s2">"tboox.org(test)"</span><span class="p">)</span>
</code></pre>
</div>

<h6 id="releasesign">ReleaseSign</h6>

<p>We can set a certificate file for release signing.</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">target</span><span class="p">(</span><span class="s2">"msdsm"</span><span class="p">)</span>
    <span class="n">add_rules</span><span class="p">(</span><span class="s2">"wdk.driver"</span><span class="p">,</span> <span class="s2">"wdk.env.wdm"</span><span class="p">)</span>
    <span class="n">set_values</span><span class="p">(</span><span class="s2">"wdk.sign.mode"</span><span class="p">,</span> <span class="s2">"release"</span><span class="p">)</span>
    <span class="n">set_values</span><span class="p">(</span><span class="s2">"wdk.sign.company"</span><span class="p">,</span> <span class="s2">"xxxx"</span><span class="p">)</span>
    <span class="n">set_values</span><span class="p">(</span><span class="s2">"wdk.sign.certfile"</span><span class="p">,</span> <span class="n">path</span><span class="p">.</span><span class="n">join</span><span class="p">(</span><span class="n">os</span><span class="p">.</span><span class="n">projectdir</span><span class="p">(),</span> <span class="s2">"xxxx.cer"</span><span class="p">))</span>
</code></pre>
</div>

<h5 id="support-low-version-system">Support Low-version System</h5>

<p>We can set <code class="highlighter-rouge">wdk.env.winver</code> to generate a driver package that is compatible with a low version system.</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">set_values</span><span class="p">(</span><span class="s2">"wdk.env.winver"</span><span class="p">,</span> <span class="s2">"win10"</span><span class="p">)</span>
<span class="n">set_values</span><span class="p">(</span><span class="s2">"wdk.env.winver"</span><span class="p">,</span> <span class="s2">"win10_rs3"</span><span class="p">)</span>
<span class="n">set_values</span><span class="p">(</span><span class="s2">"wdk.env.winver"</span><span class="p">,</span> <span class="s2">"win81"</span><span class="p">)</span>
<span class="n">set_values</span><span class="p">(</span><span class="s2">"wdk.env.winver"</span><span class="p">,</span> <span class="s2">"win8"</span><span class="p">)</span>
<span class="n">set_values</span><span class="p">(</span><span class="s2">"wdk.env.winver"</span><span class="p">,</span> <span class="s2">"win7"</span><span class="p">)</span>
<span class="n">set_values</span><span class="p">(</span><span class="s2">"wdk.env.winver"</span><span class="p">,</span> <span class="s2">"win7_sp1"</span><span class="p">)</span>
<span class="n">set_values</span><span class="p">(</span><span class="s2">"wdk.env.winver"</span><span class="p">,</span> <span class="s2">"win7_sp2"</span><span class="p">)</span>
<span class="n">set_values</span><span class="p">(</span><span class="s2">"wdk.env.winver"</span><span class="p">,</span> <span class="s2">"win7_sp3"</span><span class="p">)</span>
</code></pre>
</div>

<p>We can also set windows version for WDK driver program:</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> f --wdk_winver=[win10_rs3|win8|win7|win7_sp1]
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv">
</span></code></pre>
</div>

<h4 id="winsdk-application-program">WinSDK Application Program</h4>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">target</span><span class="p">(</span><span class="s2">"usbview"</span><span class="p">)</span>
    <span class="n">add_rules</span><span class="p">(</span><span class="s2">"win.sdk.application"</span><span class="p">)</span>

    <span class="n">add_files</span><span class="p">(</span><span class="s2">"*.c"</span><span class="p">,</span> <span class="s2">"*.rc"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"xmlhelper.cpp"</span><span class="p">,</span> <span class="p">{</span><span class="n">rule</span> <span class="o">=</span> <span class="s2">"win.sdk.dotnet"</span><span class="p">})</span>
</code></pre>
</div>

<p>If you want to known more information, you can see <a href="https://github.com/xmake-io/xmake/issues/173">#173</a>.</p>

        </article>
        <hr>

        <!-- baidu ads -->
        

        
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
                    
                    <h2 id="chinese">中文</h2>
                    <ul>
                    
                    <li class="relatedPost">
                        <a href="/cn/2018/06/17/update-v2.2.1/">xmake v2.2.1 大版本发布，Qt, WDK和Cuda编译环境支持
                        
                        </a>
                    </li>
                    
                    
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
        
            </ul>
        

        
        
            
            
            
                
                    
                        
                        <h2 id="similar_posts">Similar Posts</h2>
                        <ul>
                        
                        <li class="relatedPost">
                            <a href="/2021/12/17/xmake-update-v2.6.2/">Xmake v2.6.2 released, Support building Linux kernel driver module
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/2021/12/03/xmake-update-v2.6.1/">xmake v2.6.1 released, Switch to Lua5.4 runtime, Support Rust and C++ mixed compilation
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/2021/10/30/xmake-update-v2.5.9/">xmake v2.5.9 released, Improve C++20 Modules and support Nim, Keil MDK and Unity Build
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/2021/10/08/xmake-update-v2.5.8/">xmake v2.5.8 is released, Support Pascal/Swig program and Lua53 runtime
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/2021/08/29/xmake-update-v2.5.7/">xmake v2.5.7 released, Use lockfile to freeze package dependencies and Vala/Metal language support
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
        
            </ul>
        

        <div class="post-recent">
    <div class="pre">

        

        

        
        
        

        

        

        
        
        

        

        

        
        
        

        

        

        
        
        <p><strong>Prev Post</strong> <a href="/2018/05/30/support-qt/">XMake: Support for the Qt SDK environment</a></p>
        
    </div>

    <div class="nex">

        

        

        
        
        

        

        

        
        
        <p><strong>Next Post</strong> <a href="/2018/06/25/xmake-vscode-update-v1.0.8/">xmake-vscode v1.0.8 released, support Qt/WDK development</a></p>
        
    </div>
</div>


        <h2 id="comments">Comments</h2>
        






<div id="gitalk-container"></div>
<link rel="stylesheet" href="/css/gitalk.css">
<script src="/js/gitalk.min.js"></script>

<script>
const gitalk = new Gitalk({
  clientID: '73946dc1d9e2276ad0da',
  clientSecret: '12a3cb94361ba3ebc6ecb68cf80d592bfaa8106d',
  repo: 'tboox.github.io',
  owner: 'waruqi',
  admin: ['waruqi'],
  id: location.pathname,      
  language: 'en',
  distractionFreeMode: false  
})

gitalk.render('gitalk-container')
</script>





    </div>
    <button class="anchor"><i class="fa fa-anchor"></i></button>
    <div class="right">
        <div class="wrap">


            <!-- codefund ads -->
            

            <!-- Content -->
            <div class="side content">
                <div>
                    Content
                </div>
                <ul id="content-side" class="content-ul">
                    <li><a href="#chinese">中文</a></li>
                    <li><a href="#similar_posts">Similar Posts</a></li>
                    <li><a href="#comments">Comments</a></li>
                </ul>
            </div>

            <!-- baidu ads -->
            

            <br>
            <div class="side">
                <div>
                    <i class="fa fa-external-link"></i>
                    Links
                </div>
                <ul class="content-ul">
                  <li><a href="http://github.com/waruqi/tbox">tbox</a></li>
                  <li><a href="http://www.xmake.io">xmake</a></li>
                  <li><a href="https://github.com/waruqi">github</a></li>
                </ul>
            </div> 

            <!-- google ads -->
            

            <!-- baidu ads -->
            

            <!-- chitika ads -->
            
        </div>
    </div>

    <!-- baidu ads -->
    
</div>
<script>
/**
 * target _blank
 */
(function() {
    var aTags = document.querySelectorAll('article a:not([id])')
    for (var i = 0; i < aTags.length; i++) {
        aTags[i].setAttribute('target', '_blank')
    }
}());
</script>
<script src="/js/pageContent.js " charset="utf-8"></script>



    <footer class="site-footer">
    <div class="wrapper">
        <p class="description">
             Copyright (c) 2016-2020 tboox.org 
        </p>
        <p class="contact">
            
            <a href="https://github.com/waruqi" title="GitHub"><i class="fa fa-github" aria-hidden="true"></i></a> 
             
            
            <a href="mailto:waruqi@gmail.com" title="email"><i class="fa fa-envelope-o" aria-hidden="true"></i></a> 
            
            
            <a href="https://twitter.com/waruqi" title="Twitter"><i class="fa fa-twitter" aria-hidden="true"></i></a> 
            
            <a href="/feed.xml" title="feed"><i class="fa fa-feed" aria-hidden="true"></i></a> 
        </p>
        <p class="power">
            <span>
                Site powered by <a href="https://jekyllrb.com/">Jekyll</a> & <a href="https://github.com/Gaohaoyang">HyG</a> & <a href="https://pages.github.com/">Github Pages</a>.
            </span>
        </p>
    </div>
</footer>

    <div class="back-to-top">
    <a href="#top" class="scroll">
        <i class="fa fa-arrow-up" aria-hidden="true"></i>
    </a>
</div>

    <script src=" /js/main.js " charset="utf-8"></script>
    <script src=" /js/scroll.min.js " charset="utf-8"></script>
  </body>

</html>
